/*
 * @lc app=leetcode.cn id=27 lang=swift
 *
 * [27] 移除元素
 */

// @lc code=start
class Solution {
    func removeElement(_ nums: inout [Int], _ val: Int) -> Int {
        var left = 0, right = 0
        while right < nums.count {
            if nums[right] == val {
                right += 1
                continue
            }
            if left != right {
                nums[left] = nums[right]
            }
            left += 1
            right += 1
        }
        return left
    }
}
// @lc code=end

